package com.study.mike.common.utils;

import cn.hutool.core.util.StrUtil;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author KangHui
 * @Date 2023/3/3 11:09
 */
public class StrUtils {
    public static String swapCase(String str) {
        if (StrUtil.isBlank(str)) {
            return str;
        } else {
            char[] buffer = str.toCharArray();
            for (int i = 0; i < buffer.length; ++i) {
                char ch = buffer[i];
                if (Character.isLowerCase(ch)) {
                    buffer[i] = Character.toUpperCase(ch);
                }
            }
            return new String(buffer);
        }
    }

    public static Boolean verifyOrder(String orderId) {
        String regex = "\\d{6,12}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(orderId);
        return matcher.matches() == true ? true : false;
    }
}
